<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1.shift()返回值就是删除的元素--删除头部元素
        const arr = [2, 5, 7]
        // console.log(arr.shift());
        Array.prototype.myShift = function () {
            const re = this[0]
            for (let i = 0; i < this.length; i++) {
                this[i] = this[i + 1]
            }
            this.length = this.length - 1
            return re

        }
        console.log(arr.myShift());
        console.log(arr);
    </script>
</body>

</html>